package course.p4_list.s5_RelaxList;

import org.junit.Test;

import java.util.LinkedList;

public class TestDemo {

    public static void main(String[] args) {

        //统计jdk自带链表add 500万个元素所需时间
        LinkedList<Integer> ll = new LinkedList<Integer>();
        long endTime;
        long startTime = System.currentTimeMillis();
        for (int i = 0; i < 5000000; i++) {
            ll.add(i);
        }
        endTime = System.currentTimeMillis();
        System.out.println("Jdk实现的普通链表add500万个元素所需时间 -> " + (endTime - startTime)+"ms");
        //统计长度为500万的普通链表删除第250万个位置的元素所需时间
        startTime = System.currentTimeMillis();
        ll.remove(2500000);
        endTime = System.currentTimeMillis();
        System.out.println("普通链表删除第250万个元素所需要的时间->" + (endTime - startTime)+"ms");
        ll = null;
        System.gc();

        //相同条件下松散链表的表现
        RelaxList<Integer> ull = new RelaxList<>(16);
        startTime = System.currentTimeMillis();
        for (int i = 0; i < 5000000; i++) {
            ull.add(i);
        }
        System.out.println(ull.size());
        endTime = System.currentTimeMillis();
        System.out.println("松散链表add 500万个元素所需时间 -> " + (endTime - startTime)+"ms");
        startTime = System.currentTimeMillis();
        System.out.println(ull.remove(2500000));
        endTime = System.currentTimeMillis();
        System.out.println("松散链表删除第250万个元素所需时间->" + (endTime - startTime)+"ms");
    }


    @Test
    public void Test(){
        RelaxList<String> test1=new RelaxList<>(10);
        RelaxList<String> test2=new RelaxList<>(12);
    }

}
